﻿/*
后期部署脚本模板							
--------------------------------------------------------------------------------------
 此文件包含将附加到生成脚本中的 SQL 语句。		
 使用 SQLCMD 语法将文件包含到后期部署脚本中。			
 示例:      :r .\myfile.sql								
 使用 SQLCMD 语法引用后期部署脚本中的变量。		
 示例:      :setvar TableName MyTable							
               SELECT * FROM [$(TableName)]					
--------------------------------------------------------------------------------------
*/
alter table dbo.CodeInfo
   add constraint FK_CodeInfo_CodeCategories foreign key (CategoryId)
      references dbo.CodeCategories (CategoryId)
go

alter table dbo.FunctionInRoles
   add constraint FK_FunctionInRole_FunctionsInfo foreign key (FunctionId)
      references dbo.FunctionsInfo (FunctionId)
go

alter table dbo.FunctionInRoles
   add constraint FK_FunctionInRole_Roles foreign key (RoleId)
      references dbo.Roles (RoleId)
go

alter table dbo.GroupInRoles
   add constraint FK_GroupInRoles_Groups foreign key (GroupId)
      references dbo.Groups (GroupId)
go

alter table dbo.GroupInRoles
   add constraint FK_GroupInRoles_Roles foreign key (RoleId)
      references dbo.Roles (RoleId)
go

alter table dbo.MenuButtons
   add constraint FK_MenuButtons_ControlButtons foreign key (ControlId)
      references dbo.ControlButtons (ControlId)
go

alter table dbo.MenuButtons
   add constraint FK_MenuButtons_FunctionsInfo foreign key (FunctionId)
      references dbo.FunctionsInfo (FunctionId)
go

alter table dbo.RoleAuthorizes
   add constraint FK_RoleAuthorizes_AuthorizeCodes foreign key (AuthorizeCodeId)
      references dbo.AuthorizeCodes (AuthorizeCodeId)
go

alter table dbo.RoleAuthorizes
   add constraint FK_RoleAuthorizes_Roles foreign key (RoleId)
      references dbo.Roles (RoleId)
go

alter table dbo.RoleColumns
   add constraint FK_RoleColumns_FunctionsInfo foreign key (FunctionId)
      references dbo.FunctionsInfo (FunctionId)
go

alter table dbo.RoleColumns
   add constraint FK_RoleColumns_Roles foreign key (RoleId)
      references dbo.Roles (RoleId)
go

alter table dbo.RoleMenuButtons
   add constraint FK_RoleMenuButtons_ControlButtons foreign key (ControlId)
      references dbo.ControlButtons (ControlId)
go

alter table dbo.RoleMenuButtons
   add constraint FK_RoleMenuButtons_FunctionsInfo foreign key (FunctionId)
      references dbo.FunctionsInfo (FunctionId)
go

alter table dbo.RoleMenuButtons
   add constraint FK_RoleMenuButtons_Roles foreign key (RoleId)
      references dbo.Roles (RoleId)
go

alter table dbo.UserInGroups
   add constraint FK_UserInGroup_Groups foreign key (GroupId)
      references dbo.Groups (GroupId)
go

alter table dbo.UserInGroups
   add constraint FK_UserInGroup_Users foreign key (UserId)
      references dbo.Users (UserId)
go

alter table dbo.UserInRoles
   add constraint FK_UserRoles_Roles foreign key (RoleId)
      references dbo.Roles (RoleId)
go

alter table dbo.UserInRoles
   add constraint FK_UserRoles_Users foreign key (UserId)
      references dbo.Users (UserId)
go

alter table dbo.UserofSettings
   add constraint FK_UserofSettings_Users foreign key (UserId)
      references dbo.Users (UserId)
go

alter table dbo.Users
   add constraint FK_Users_UserGroups foreign key (GroupId)
      references dbo.Groups (GroupId)
go

alter table dbo.Users
   add constraint FK_Users_UserofSettings foreign key (UserSettingId)
      references dbo.UserofSettings (UserSettingId)
go
